//
// Created by Administrator on 2020/7/2.
//

#ifndef AVPLAYER_NEFFMPEG_H
#define AVPLAYER_NEFFMPEG_H


#include "JavaCallHelper.h"
#include "AudioChannel.h"
#include "VideoChannel.h"
#include "cstring"
#include "macro.h"
#include <pthread.h>

extern "C" {
#include <libavformat/avformat.h>
};

//typedef void (*RenderCallback)(uint8_t *, int, int, int);

class NEFFmpeg {
public:
    NEFFmpeg(JavaCallHelper *javaCallHelper, char *dataSource);

    ~NEFFmpeg();

    void prepare();

    void _prepare();

    void start();

    void _start();

    void setRenderCallback(RenderCallback renderCallback);

private:
    JavaCallHelper *javaCallHelper = 0;
    AVFormatContext *avFormatContext = 0;
    AudioChannel *audioChannel = 0;
    VideoChannel *videoChannel = 0;
    char *dataSource = 0;
    pthread_t pid_prepare, pid_start;
    bool isPlaying = 0;
    RenderCallback renderCallback;
};


#endif //AVPLAYER_NEFFMPEG_H
